﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Requisitos.aspx.cs" Inherits="Ent.Inscripcion.Presentacion.Administracion.Requisitos" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Administrar Requisitos</title>
    <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="Script" />
    <script type="text/javascript" src="../Resources/Js/EntInscripcion.js"></script>
</head>
<body>
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:Hidden ID="hidIdRequisito" runat="server">
    </ext:Hidden>
    <ext:Hidden ID="hidAccionRequisito" runat="server">
    </ext:Hidden>
    <ext:Viewport ID="ViewPort1" runat="server" Layout="Fit">
        <LayoutConfig>
            <ext:VBoxLayoutConfig Align="Stretch" />
        </LayoutConfig>
        <Items>
            <ext:Panel ID="Panel2" BodyStyle="background-color:transparent;" Padding="10" Border="false"
                runat="server" ButtonAlign="Center">
                <Items>
                    <ext:FormPanel ID="frpDatosBusqueda" BodyStyle="background-color:transparent;" runat="server"
                        Border="false" Layout="Column" LabelWidth="70" ButtonAlign="Center">
                        <Items>
                            <ext:Panel ID="Panel3" runat="server" ColumnWidth="0.5" Height="25" Border="false"
                                Layout="Form">
                                <Items>
                                    <ext:TextField runat="server" ID="txtBNombre" AnchorHorizontal="90%" FieldLabel="Nombre">
                                    </ext:TextField>
                                </Items>
                            </ext:Panel>
                            <ext:Panel ID="Panel6" runat="server" ColumnWidth="0.5" Border="false" Layout="Form">
                                <Items>
                                    <ext:CheckboxGroup ID="CheckboxGroup1" runat="server" FieldLabel="Tipo" AnchorHorizontal="60%">
                                        <Items>
                                            <ext:Checkbox ID="chkBTutoria" runat="server" BoxLabel="Tutoria" Checked="true" />
                                            <ext:Checkbox ID="chkBExamen" runat="server" BoxLabel="Examen" Checked="true" />
                                        </Items>
                                    </ext:CheckboxGroup>
                                </Items>
                            </ext:Panel>
                        </Items>
                        <Buttons>
                            <ext:Button ID="btnBuscar" runat="server" Text="Buscar">
                                <DirectEvents>
                                    <Click Before="#{stoRequisitos}.removeAll();" OnEvent="btnBuscar_Click">
                                        <ExtraParams>
                                            <ext:Parameter Name="Nombre" Value="#{txtBNombre}.getValue()" Mode="Raw">
                                            </ext:Parameter>
                                            <ext:Parameter Name="Tutoria" Value="#{chkBTutoria}.getValue()" Mode="Raw">
                                            </ext:Parameter>
                                            <ext:Parameter Name="Examen" Value="#{chkBExamen}.getValue()" Mode="Raw">
                                            </ext:Parameter>
                                        </ExtraParams>
                                        <EventMask Msg="Buscando Requisitos" ShowMask="true" />
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </Buttons>
                    </ext:FormPanel>
                </Items>
            </ext:Panel>
            <ext:GridPanel ID="gdpRequisitos" runat="server" StripeRows="true" AutoWidth="true"
                Height="600" AutoExpandColumn="Nombre">
                <Store>
                    <ext:Store runat="server" ID="stoRequisitos">
                        <Reader>
                            <ext:JsonReader IDProperty="Id">
                                <Fields>
                                    <ext:RecordField Name="Id" />
                                    <ext:RecordField Name="Nombre" />
                                    <ext:RecordField Name="Tipo" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <TopBar>
                    <ext:Toolbar ID="Toolbar3" runat="server">
                        <Items>
                            <ext:Button ID="btnCrearRequisito" runat="server" Text="Crear Requisito" Icon="PageAdd">
                                <Listeners>
                                    <Click Handler="LimpiarForm();#{winRequisitos}.show();#{hidAccionRequisito}.setValue('Nuevo');" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel ID="ColumnModel3" runat="server">
                    <Columns>
                        <ext:CommandColumn Width="120" Header="Acciones">
                            <Commands>
                                <ext:GridCommand CommandName="Editar" Text="Editar" Icon="PageEdit" ToolTip-Text="Editar Requisito">
                                </ext:GridCommand>
                                <ext:GridCommand CommandName="Eliminar" Text="Eliminar" Icon="PageDelete" ToolTip-Text="Eliminar Requisito">
                                </ext:GridCommand>
                            </Commands>
                        </ext:CommandColumn>
                        <ext:Column Header="Tipo" Width="80" Sortable="true" DataIndex="Tipo" />
                        <ext:Column ColumnID="Nombre" Header="Nombre" Width="150" Sortable="true" DataIndex="Nombre"/>
                    </Columns>
                </ColumnModel>
                <DirectEvents>
                    <Command OnEvent="ManejarAccion">
                        <ExtraParams>
                            <ext:Parameter Name="Comando" Value="command" Mode="Raw" Encode="false" />
                            <ext:Parameter Name="Id" Value="record.data.Id" Mode="Raw" />
                        </ExtraParams>
                    </Command>
                </DirectEvents>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel3" runat="server" SingleSelect="true">
                    </ext:RowSelectionModel>
                </SelectionModel>
                <LoadMask Msg="Cargando Datos" ShowMask="true" />
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
    <ext:Window ID="winRequisitos" runat="server" Icon="Application" Title="Administrar Requisitos"
        Modal="True" AutoHeight="true" Width="400px" Y="5" CenterOnLoad="true" Hidden="true"
        ButtonAlign="Center">
        <Items>
            <ext:FormPanel ID="frpDatosRequisito" runat="server" BodyStyle="padding:10px;" ButtonAlign="Center"
                Layout="Form" Hidden="false" AnimCollapse="true" LabelWidth="80">
                <Items>
                    <ext:TextField runat="server" ID="txtNombre" AnchorHorizontal="95%" FieldLabel="Nombre">
                    </ext:TextField>
                    <ext:ComboBox ID="cbTipo" runat="server" Editable="false" DisplayField="text" AllowBlank="false"
                        ValueField="value" FieldLabel="Tipo" Mode="Local" AnchorHorizontal="95%" EmptyText="Seleccione..">
                        <Items>
                            <ext:ListItem Text="Tutoría" Value="Tutoria" />
                            <ext:ListItem Text="Exámen" Value="Examen" />
                        </Items>
                        <ToolTips>
                            <ext:ToolTip runat="server" Title="Tipo">
                            </ext:ToolTip>
                        </ToolTips>
                    </ext:ComboBox>
                </Items>
            </ext:FormPanel>
        </Items>
        <Buttons>
            <ext:Button runat="server" ID="btnEliminar" Text="Eliminar" Hidden="true" Icon="Delete">
                <DirectEvents>
                    <Click OnEvent="btnEliminar_Click" Failure="ManejarError();" Success="LimpiarForm();#{winRequisitos}.hide();MostrarMensaje(3,'El requisito se elimino correctamente');">
                        <EventMask ShowMask="true" Msg="Eliminando Requisito" />
                        <ExtraParams>
                            <ext:Parameter Name="Id" Value="#{hidIdRequisito}.getValue()" Mode="Raw" />
                        </ExtraParams>
                        <Confirmation Message="Esta seguro de eliminar el Requisito?" ConfirmRequest="true" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:Button runat="server" ID="btnGuardar" Text="Guardar" Icon="Add">
                <DirectEvents>
                    <Click Before="return ValidarFormulario(#{frpDatosRequisito});" OnEvent="btnGuardar_Click"
                        Failure="ManejarError();" Success="LimpiarForm();#{winRequisitos}.hide();MostrarMensaje(3,'El requisito se guardo correctamente');">
                        <EventMask ShowMask="true" Msg="Guardando datos" />
                        <ExtraParams>
                            <ext:Parameter Name="Accion" Value="#{hidAccionRequisito}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="Id" Value="#{hidIdRequisito}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="Tipo" Value="#{cbTipo}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="Nombre" Value="#{txtNombre}.getValue()" Mode="Raw" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:Button runat="server" ID="btnCancelar" Text="Cancelar" Icon="Stop">
                <Listeners>
                    <Click Handler="LimpiarForm();#{winRequisitos}.hide();" />
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
    <ext:XScript ID="XScript1" runat="server">

    <script type="text/javascript">
        var LimpiarForm = function () { 
            #{frpDatosRequisito}.getForm().reset();
        };
    </script>
    </ext:XScript>
</body>
</html>
